# Author   : zhen.fang
# Time     : 2021/1/1 15:48
# Email    : fangeddie@163.com
from rest_framework import serializers
from .models import Account


class AccountSerializer(serializers.ModelSerializer):
    # write_only 表示序列化时不会序列该字段, read_only 相反
    id = serializers.CharField(max_length=20, read_only=True)
    password = serializers.CharField(max_length=256, style={'input_type': 'password'}, write_only=True)
    deposit = serializers.CharField(source='wallet.deposit', read_only=True)
    on_delete = serializers.BooleanField(default=False)

    class Meta:
        model = Account
        fields = ('id', 'username', 'gender', 'password', 'mobile', 'avatar', 'deposit', 'role', 'on_delete')


class SubscribeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Account
        fields = '__all__'
